package com.boarsoft.boar.demo;

import com.boarsoft.boar.demo.dao.OrderDao;
import com.boarsoft.boar.demo.order.entity.PocOrder;
import com.boarsoft.dao.sharding.aspect.ShardingKeyContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;
import java.util.Random;

public class Main {
	private static ClassPathXmlApplicationContext ctx;
	public static void main(String[] args){
		ctx = new ClassPathXmlApplicationContext("classpath:conf/context.xml");
		ShardingKeyContext.set("00");
		PocOrder order=new PocOrder();
		order.setOrderId(new Random().nextInt(200000));
		order.setProductId(1);
		order.setProductNum(1);
		order.setStatus((short) 0);
		order.setTenantId(1111);
		order.setUserId(111);
		order.setAmount(100);
		order.setCreateTime("2023-01-01");
		order.setModifyTime("2023-01-01");
		((OrderDao)ctx.getBean("orderDao")).insert(order);

		ShardingKeyContext.set("51");
		((OrderDao)ctx.getBean("orderDao")).insert(order);
	}
}
